package com.cardbaobao.cardbabyclient.widget;

import android.content.Context;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.cardbaobao.cardbabyclient.R;

/**
 * 搜索没有结果提示的View
 * Created by zad
 * 2017/2/27 10:01
 */

public class SearchNotDataTipView extends LinearLayout {

    private View mContainer;

    private LinearLayout mLLNotDataTip;

    private ImageView mIvTipIcon;

    private TextView mTvNotDataTxt;

    private TextView mTvSuggestTxt;

    private TextView mTvToOther;

    public SearchNotDataTipView(Context context) {
        this(context,null);
    }

    public SearchNotDataTipView(Context context, AttributeSet attrs) {
        this(context, attrs,0);
    }

    public SearchNotDataTipView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        initView(context);
    }

    private void initView(Context context){
        mContainer = LayoutInflater.from(context).inflate(R.layout.layout_tip_not_search_data,this);
        mLLNotDataTip = (LinearLayout) mContainer.findViewById(R.id.id_ll_not_data_tip);
        mLLNotDataTip.setVisibility(GONE);
        mIvTipIcon = (ImageView) mContainer.findViewById(R.id.id_iv_not_data_show);
        mTvNotDataTxt = (TextView) mContainer.findViewById(R.id.id_tv_no_data_tip);
        mTvSuggestTxt = (TextView) mContainer.findViewById(R.id.id_tv_no_data_tip_suggest);
        mTvSuggestTxt.setVisibility(GONE);
        mTvToOther = (TextView) mContainer.findViewById(R.id.id_tv_not_data_to);
        mTvToOther.setVisibility(GONE);
    }

    /**
     * 没有数据显示
     * @param mTipContent 提示内容
     */
    public void show(String mTipContent){
        setVisibility(VISIBLE);
        mLLNotDataTip.setVisibility(VISIBLE);
        mTvSuggestTxt.setVisibility(GONE);
        if(!TextUtils.isEmpty(mTipContent)){
            mTvNotDataTxt.setText(mTipContent);
        }
    }

    /**
     * 有数据隐藏
     */
    public void hide(){
        setVisibility(GONE);
        mLLNotDataTip.setVisibility(GONE);
        mTvSuggestTxt.setVisibility(GONE);
    }

    /**
     * 没有数据显示并提示建议
     */
    public void showAndSuggest(String mTipContent){
        show(mTipContent);
        mTvSuggestTxt.setVisibility(VISIBLE);
    }
}
